//
import * as React from "react";
import { Menu, Icon } from 'antd';
//
import * as mvc from "common/mvc";
//
import * as dbtps from "../../types";
import * as language from "../../language";

const SubMenu = Menu.SubMenu;
const ItemGroup = Menu.ItemGroup;
const Item = Menu.Item;
const Divider = Menu.Divider;

const enum MenuKey {
    None,
    NewDocument,
    Imporrt,
    Export,
    Help,
}

export default class TopMenuComponent extends React.Component<any, any> {
    render() {
        return (
            <Menu
                theme="dark"
                mode="horizontal"
                onClick={
                    (e) => {
                        switch (Number(e.key)) {
                            case MenuKey.NewDocument:
                                mvc.context.sendNotification(dbtps.CNotificationType.NewDocument, null);
                                break;

                            case MenuKey.Help:
                                mvc.context.sendNotification(dbtps.VNotificationType.HelpMenu, null);
                                break;
                        }
                    }
                }
                >
                <SubMenu key="icon" title={<Icon type="apple" />}>
                    <Item key={MenuKey.NewDocument}>{language.get(language.TopMenu.dragonBones.newDocument)}</Item>
                    <Item key="setting:2">Option 2</Item>
                    <Divider />
                    <Item key="setting:3">Option 3</Item>
                    <Divider />
                    <Item key="setting:4">Option 4</Item>
                </SubMenu>
                <SubMenu title={<Icon type="layout" />}>
                    <ItemGroup title="Item 1">
                        <Item key="setting:1">Option 1</Item>
                        <Item key="setting:2">Option 2</Item>
                    </ItemGroup>
                    <ItemGroup title="Item 2">
                        <Item key="setting:3">Option 3</Item>
                        <Item key="setting:4">Option 4</Item>
                    </ItemGroup>
                </SubMenu>
                <Item key={MenuKey.Help}>
                    <Icon type="question-circle-o" />
                </Item>
            </Menu>
        );
    }
}